How to write plugins
--------------------------

I do not like writing manuals whatsoever, thus this will be only a short description 
what plugins must do. I believe the sample skeleton plugin is a good starting point 
as it contains all necessary functions.
At the moment, plugins can be created only with Delphi.


1. BUTTON IMAGES
Each plugin must have two resource bitmaps, HOTIMAGE and BWIMAGE. 
These images are used in a button created for plugin in main window so that the BWIMAGE 
is the normal state of the button and HOTIMAGE will be shown when mouse is 
over the button. The image size must be 32x32 pixels and the transparent color
must be RGB(255,0,255). 
When these two images are ready, create a resource file (e.g. buttons.rc) and 
insert following lines (assuming that filenames are hot.bmp and bw.bmp):

HOTIMAGE Bitmap hot.bmp
BWIMAGE Bitmap bw.bmp

Then, with BRCC32.EXE, compile the resource file:
BRCC32 -v buttons.rc 

As a result, there should be a file buttons.res in the directory. Include this 
file in your library source file:
{$R buttons.RES}



2. PROCEDURE ShowPlugin
The plugin must export procedure ShowPlugin. As we want to have the plugin's
form shown as MDI child form, we must pass TApplication and TScreen from the 
main application to plugin DLL. There is also one additional parameter, index
that is used in creation phase. If index is greater than 0 then the plugin 
should read it's parameters (position etc) from the registry. File pub.pas contains 
functions and procedures for saving and retrieving data to and from registry.

The ShowPlugin procedure is declared as follows:
procedure ShowPlugin(MainApp : TApplication; MainScreen : TScreen; index : Integer); stdcall;

When the main application and the plugin is created, the main application will 
start to send messages for the plugin. If the child form's Tag is 0 then the form
will receive all the messages from every sensor in the system. If the Tag is > 0 then
the form will receive only messages from the sensor that has the same Tag value. 
See the registry, that will clarify this... 
All the plugin must do is to respond (or not) to these messages. The only "mandatory" 
message where the plugin must respond is the message WM_SavePosition. It is a 
notification that the main application is closing and children are requested to save 
their operational parameters to registry under the key 
HKEY_LOCAL_MACHINE/Software/TSa/Temp/Windows/### 
where ### is an index number indicated by the LPARAM of message WM_SavePosition.
Other possible messages (defined in pub.pas) are:

   WM_TempNotify 	// wParam = Sensor lParam=temp*100
   WM_AvgTempNotify 	// wParam = Sensor lParam=Averagetemp*100
   WM_AlarmNotify	// wParam = Sensor lParam= 2=High 1=Low 0=No alarm
   WM_AlarmReNotify	// Same as above but this message is sent every time a new form is opened
   WM_SlopeNotify	// WParam=Sensor LParam=Type; 0=End, 1=Falling 2=Raising
   WM_LanguageChanged	// Language changed

New in version 1.11.
   WM_SaveImage		// It is time to save image. 
   Image type (BMP (0) or JPEG (1)) and image path is in registry under key General/ImageType and ImagePath.

Note, that messages WM_TempNotify and WM_AvgTempNotify contains the temperature 
multiplied by 100!

Rest of the documentation is in the source files.


3. SAMPLE PLUGINS
-----------------
There are two sample plugins, CustomForm and Skeleton. The skeleton is not useful for any 
purpose but, as it is as simple as possible, it is a good starting point for creating 
your own plugins. The Customform is a plugin to show user customizable forms. The main idea 
is that there is a background image and simple labels on it. 
The creation of the form is controlled by the intialization file having extension
.cuf. In fact, it is an old fashion (but still useful) windows .ini file. 
Each .cuf file must have a section [Main] that contains following  name/value pairs
[Main]
Top=10
Left=20
Width=400
Height=200
Back=background.bmp
UseFahrenheit=0

I guess these won't need an explanation...

The rest of the sections describe how to create the labels. 
If the section name matches the name of a sensor in the system, that label will 
receive the appropriate temperature notification messages. These "sensorlabels" must have 
Caption set so that the temperature string can be inserted into it e.g. "Fixed text %s". 
In this case, the label will be for example "Fixed text 12.86  F"

If the section name does not match with any of the sensor names in the system, then
this label contains simply text that is  defined in Caption line.

Another possible setting for the label sections are:
Top=			 Top of the label
Left=			 Left of the label
Width=			 Width of the label
Height=			 Height of the label, also controls the font size
Color=			 Color of the background of the label. Has no effect if Transparent=1
Caption=Outdoors %s	 Caption of the label. The %s will be replaced with the temperature value
Transparent=0		 Transparent or not
FontBold=1		 Font is bold
FontColor=$FF00FF	 Font color when no alarm
FontName=Courier	 Font type face
FontAlarmHiColor=$00FFFF Alarm color
FontAlarmLoColor=$FF0000 Alarm color


Note, that the color values are in format BGR!



And finally, plugin DLL's MUST reside in the directory "plugins". 

